layui.use("formSelects",function () {
    var form = layui.form,laydate=layui.laydate,formSelects = layui.formSelects,id=getQueryVariable("id");
    laydate.render({
        elem: '#cdate'
    });
    //自定义表单验证
    form.verify({
        Ndouble:[
            /^[1-9]\d*$/
            ,'只能输入整数哦'
        ]
    });

    //动态赋值客户类型
    formSelects.data('customertype', 'local', {
        arr: [
            {"name": "类型1", "value": 1},
            {"name": "类型2", "value": 2},
            {"name": "类型3", "value": 3},
            {"name": "类型4", "value": 4},
            {"name": "类型5", "value": 5}
        ]
    });
    layui.formSelects.value('customertype', [1, 2]);
    form.render('select');

    //表单初始值，修改时调用
    if(id!=""){
        form.val("pubicpool-form",{
            "customersource":"客户来源",
        })
    }

    //监听提交
    form.on('submit(form-element)', function(data){
        //data.field为表单数据
        layer.msg("保存成功", {icon: 6});
        setTimeout(function () {
            //保存成功则刷新提交过来的界面 并关闭此页面
            parent.detab("views/jsp/BasicData/tpl/commonsettings.jsp");
            parent.intab("views/jsp/BasicData/tpl/commonsettings.jsp","公共池设置")
            parent.detab("views/jsp/BasicData/tpl/newuppubicpool.jsp"+(id==''?'':'?id='+id));
        },1000)
        //关闭窗口
        // parent.detab("views/jsp/SystemCenter/tpl/newupmenu.jsp"+(authorityId==''?'':'?authorityId='+authorityId));
        return false;
    });
})